/*
 *        (C) COPYRIGHT Ingenic Limited.
 *             ALL RIGHTS RESERVED
 *
 * File       : magik_model_parse_config.h
 * Authors    : llzhao
 * Create Time: 2024-06-03:10:38:51
 * Description:
 *
 */

#ifndef __COMMON_TYPE_H__
#define __COMMON_TYPE_H__

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Custom model encryption function.
 * @param original_model     original model data.
 * @param model_size         original model data size.
 * @param key                encrypted key.
 * @return The encrypted model and the encrypted model size.
 */
typedef void (*EncryptionModelFuncPtr)(const char *original_model,
                                       int model_size, const char *key,
                                       char **encry_model,
                                       int *encry_model_size);

/**
 * @brief Decrypt user-encrypted model.
 * @param encrypted_model    encrypted model data.
 * @param model_size         encrypted model data size.
 * @param key                encrypted key.
 * @return The decrypted model and the decrypted model size.
 */
typedef void (*DecryptionModelFunc)(const char *encrypted_model, int model_size,
                                    const char *key, char **decry_model,
                                    int *decry_model_size);

typedef struct {
  DecryptionModelFunc func;
  const char *key;
} MagikModelDecoder;

typedef enum {
  ModelPathType_File = 0,   /* magik model file */
  ModelPathType_Memory = 1, /* magik model data pointer */
} ModelPathType;

typedef struct {
  /// model path type
  ModelPathType model_path_type;
  /// model memory size
  int64_t model_memory_size;
  /// user-specified static data pointer.
  void *static_data;
  /// magik model decryption function.
  MagikModelDecoder *model_decoder;
} MagikModelParseConfig;

#ifdef __cplusplus
}
#endif

#endif /* __COMMON_TYPE_H__ */
